from okex.OkcoinSpotAPI import *
import json
url = 'www.okex.com'

def GetCoinNum(coinjson, ak, sk):
    ocs = OKCoinSpot(url, ak, sk)
    coins = ocs.userinfo()
    coinsjson = json.loads(coins)
    #print(coinsjson)
    myCoins = coinsjson['info']['funds']
    for i in myCoins.keys():
        myCoin = myCoins[i]
        for j in myCoin.keys():
            num = (float)(myCoin[j])
            if j == 'bch':
                continue
            if num > 0:
                if (j in coinjson.keys()):
                    coinjson[j] = coinjson[j] + num
                else:
                    coinjson[j] = num
if __name__ == '__main__':
    GetCoinNum(json.loads('{}'), "ea252b6d-1976-4ae6-9ead-3c9a95e669f9", "D54AD06C7AC88D376716CF670F2B8796")